<!--
 * @Author: your name
 * @Date: 2022-01-14 12:25:57
 * @LastEditTime: 2022-01-15 19:38:25
 * @LastEditors: Please set LastEditors
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: \算法测试\day0906\定时器.html
-->
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        /**
 * @param {number} n
 * @return {number}
 */
        var totalMoney = function (n) {
            let money = 0;
            if (n < 8) {
                for (let i = 1; i <= n; i++) {
                    money += i;
                }
                return money;
            }
            let day = n % 7;
            let week = parseInt(n / 7);
            for (let i = 28; i <= (week - 1) * 7 + 28; i+=7) {
                money += i;
            }
            for (let i = week + 1; i <= week + day; i++) {
                money += i;
            }
            return money;
        };
        console.log(totalMoney(10));
    </script>
</body>

</html>